package com.its.cloud.controller;

import com.its.cloud.entity.ResultBean;
import com.its.cloud.service.PaymentFeignService;
import com.its.cloud.service.PaymentFeignServiceImpl;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author huguangjun
 * @className PaymentController
 * @date 2021/1/11
 * @desc 17:47
 */
@RestController
public class PaymentController {

    @Resource
    private PaymentFeignService paymentService;

    @GetMapping("/consumer/payment/get/{id}")
//    @HystrixCommand(fallbackMethod = "method1", commandProperties = {
//            // 断路器设置此方法为XX秒
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000")
//    })
    public ResultBean get(@PathVariable("id") Long id) {
        try {
        } catch (Exception e) {
            e.printStackTrace();
        }
        return paymentService.get(id);
    }

    public ResultBean method1(Long id) {
        return new ResultBean("请求超时：" + id);
    }

}
